package dbscripts.util

import java.util.concurrent.atomic.AtomicInteger;

class GenId {
    static AtomicInteger seq = new AtomicInteger(0);
    static long workId = (long) (new Random(System.nanoTime())).nextInt(2048);

    static long generate() {
        return System.currentTimeMillis() << 21 | workId << 10 | (long) seq.getAndUpdate({ operand ->
            ++operand;
            return operand % 1024;
        });
    }
}
